package com.xxxx.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;


@Configurable
public class RabbitMqConfig {

    @Bean
    public Queue queue(){
        return new Queue("mq");
    }

    @Bean
    TopicExchange topicExchange(){
    return  new TopicExchange("topic");
    }

    //相当于将queue与主题交换机中routing_key="mq"绑定  传来的主题mqText没法进入队列
    @Bean
    Binding bindingQueue(Queue queue, TopicExchange topicExchange) {
        return BindingBuilder.bind(queue).to(topicExchange).with("mq");
    }

}
